package com.ls.netty.inboundoutboundhandler.coder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class MyByteToLongDecoder extends ByteToMessageDecoder {
    /**
     *
     *
     * @param ctx
     * @param in 入站
     * @param out 传给下一个handler 的集合
     * @throws Exception
     */
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("MyByteToLongDecoder decode invoke");
        if (in.readableBytes() >= 8){
            out.add(in.readLong());
        }
    }
}
